import { isBoolean, isFunction, isUndefined } from "@/utils"

/**
 * 可见性状态配置，默认为 true
 */
export interface VisibleProps {
    visible?: boolean | ((...args: any[]) => boolean)
}

/**
 * 是否可见
 * @param props 配置
 * @param args 入参
 */
export function isVisible(props: VisibleProps, ...args: any[]): boolean {
    const { visible } = props
    if (isUndefined(visible)) {
        return true
    }
    if (isBoolean(visible)) {
        return visible as boolean
    }
    if (isFunction(visible)) {
        return (visible as Function)(...args)
    }
    console.log("可见性格式错误：" + visible)
    return false
}
